package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	UserName string `gorm:"type:varchar(20);not null"`
	Phone    string `gorm:"type:char(11);not null"`
	Password string `form:"type:varchar(32)"`
}
type RealName struct {
	gorm.Model
	UserId   int    `gorm:"type:int;not null"`
	UserName string `form:"type:varchar(20);not null"`
	IdCard   string `form:"type:char(18);not null"`
}

func (u *User) Create() error {
	return DB.Create(&u).Error
}
func (u *User) UserInfoUsername(username string) error {
	return DB.Where("user_name", username).Find(&u).Error
}
func (ur *RealName) Create() error {
	return DB.Create(&ur).Error
}
func (ur *RealName) GetRealName(userid int64, idcard string) error {
	return DB.Where("user_id =? or id_card =?", userid, idcard).Find(&ur).Error
}
